PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Name

The Name reference form specifies an object by name.

SYNTAX
className [ named ] nameString

where

className is the class identifier for the specified object.

nameString is the value of the object's Name property (see "Notes").

EXAMPLES

The following statements identify an object by its name:

close document "Report" -- document identified by its name property close window named "Help" -- window identified by its name property

Note the distinction between a statement that specifies the actual name of an object, a statement that specifies an object by name, and a statement that specifies a reference to a name object:

--Specify name of file:
tell application "Finder"
    name of first file in extensions folder
end tell
--result: "LaserWriter 8" (a name string)
--Specify file by name:
tell application "Finder"
     file "LaserWriter 8" in extensions folder
end tell
--result:
-- file "LaserWriter 8" of folder "Extensions" of folder "System 8.5.1"
-- of startup disk of application "Finder" (a file object reference)
--Specify reference to name of file:
tell application "Finder"
    a reference to name of first file in extensions folder
end tell
--result: name of file 1 of extensions folder of application "Finder"
-- (a name object reference)
NOTES

In some applications, it is possible to have multiple objects of the same class in the same container with the same name. For example, if there are two drives named "Hard Disk", the following statement is ambiguous (at least to the reader):

tell application "Finder"
    file 1 of disk "Hard Disk"
end tell

In such cases, it is up to the application to determine which object is specified by a Name reference.

For applications and files, the nameString parameter can be a string of the form " Disk : Folder1 : Folder2 :... FileName " ; for details, see References to Files and Applications.

For more information about Name properties of specific types of objects, see the definitions for object classes provided by the AppleScript documentation or the application's documentation.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)